import { GraphQLError } from 'graphql'
import { ApolloError } from 'apollo-client'
import Vue from 'vue'
import { gqlErrorHandler } from '@/util/errorHandler'

Vue.config.errorHandler = (err, vm, info) => {
  console.log('Vue.errorHandler')
  if (err instanceof ApolloError || err instanceof GraphQLError) {
    if (gqlErrorHandler(vm, err)) {
      return
    }
  }

  // not handled throw
  throw err
}
